package com.ruoyi.web.controller.vantController.provincesController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.system.domain.zhuangxiumain.provinces.City;
import com.ruoyi.system.domain.zhuangxiumain.provinces.Province;
import com.ruoyi.system.domain.zhuangxiumain.provinces.Town;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.BrandInfo;
import com.ruoyi.system.service.zhaungxiuservice.provincesService.ProvinceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "省市区接口", tags = {"省市区接口"})
@RestController
@RequestMapping("/api/provinces")
@CrossOrigin
public class ProvincesController extends BaseController {


    @Autowired(required = false)
    private ProvinceService provinceService;


    @ApiResponses({@ApiResponse(code = 200, message = "正常", response = BrandInfo.class)})
    @ApiOperation(value = "查询所有身份信息")
    @GetMapping(value ="/province")
    public List<Province> findAllProvince(){
        return provinceService.findAllProvince();
//        startPage();
//        List<Province> list = provinceService.findAllProvince();
//        return getDataTable(list);
    }

    @ApiResponses({@ApiResponse(code = 200, message = "正常", response = BrandInfo.class)})
    @ApiOperation(value = "根据省份编号查询市级信息")
    @GetMapping(value ="/city/{provinceCode}")
    public List<City> findAllCity(@PathVariable("provinceCode") String provinceCode){
        return provinceService.findAllCity(provinceCode);
    }

    @ApiResponses({@ApiResponse(code = 200, message = "正常", response = BrandInfo.class)})
    @ApiOperation(value = "根据市级编号查询区域信息")
    @GetMapping(value ="/town/{cityCode}")
    public List<Town> findAllTown(@PathVariable("cityCode") String cityCode){
        return provinceService.findAllTown(cityCode);
    }



}
